﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace ServerService
{
    public class UserMsg : IComparable
    {
        private string name;
        private string msg;
        private DateTime date;

        public string Name {
            get { return name; }
            set { name = value; } 
        }
        public string Msg {
            get { return msg; }
            set { msg = value; } 
        }
        public DateTime Date {
            set { date = value; }
        }

        #region IComparable Members

        /// <summary>
        /// Porównuje UserMsg co pozwoli methodzie
        /// GetNewMessages na zwrócenie w porządku rosnącym
        /// aktualnych wiadomości (zgodnie z czasem wysłania)
        /// </summary>
        /// <param name="obj">Inny obiekt klasy UserMsg</param>
        /// <returns>1, -1, 0</returns>
        int IComparable.CompareTo(object obj)
        {
            UserMsg another = obj as UserMsg;

            if (this.date > another.date)
                return 1;
            else if (this.date < another.date)
                return -1;
            else
                return 0;
        }

        #endregion
    }
}
